import java.io.FileReader;
import java.util.Scanner;

/**
 * @author : MAO
 * @fileName : LCS_Suffxi.java
 * 
 * 
 * 
 * date | author | version | 2012-3-25 | Administrator | 1.0 |
 * 
 * @describe : Longest Common Substring
 * 
 * Note: maximum strings number <= 1000! maxlen <= 1000 per string ( heap space
 * limit )
 * 
 * ALL RIGHTS RESERVED,COPYRIGHT(C) iFocus 2012
 */

public class LCS_Suffxi {

	String path = ""; // input file path, the 1st line of the file represents
						// totoal line number

	String ans = ""; // lcs

	int max_strings = 30001; // to modify heap space size -Xmx1024m for 300k
								// strings

	int max_per_len = 1001;

	int maxn = max_strings * max_per_len; // max_arry_size = v*s

	int n, m;

	int[] be = new int[maxn];

	int[] a = new int[maxn];

	int[] rank = new int[maxn];

	int[] sa = new int[maxn];

	int[] tmp = new int[maxn];

	int[] tt = new int[maxn];

	int[] sum = new int[maxn];

	int[] h = new int[maxn];

	LCS_Suffxi(String _path) {
		path = _path;
	}

	boolean[] v = new boolean[max_strings]; // string num

	String s = ""; // max_per_len = 1000

	void da() {
		int i, j, k, m = maxn - 1;
		for (i = 1; i <= n; i++)
			sum[a[i]]++;
		for (i = 1; i <= m; i++)
			sum[i] += sum[i - 1];
		for (i = n; i >= 1; i--)
			sa[sum[a[i]]--] = i;
		for (k = 1, rank[sa[1]] = 1, i = 2; i <= n; i++) {
			if (a[sa[i]] != a[sa[i - 1]])
				k += 1;
			else
				k += 0;
			rank[sa[i]] = k;
		}
		for (j = 1; k < n; j *= 2, m = k) {
			for (k = 0, i = n - j + 1; i <= n; i++)
				tmp[++k] = i;
			for (i = 1; i <= n; i++)
				if (sa[i] > j)
					tmp[++k] = sa[i] - j;
			sum = null;
			sum = new int[maxn];
			for (i = 1; i <= n; i++) {
				tt[i] = rank[tmp[i]];
				sum[tt[i]]++;
			}
			for (i = 1; i <= m; i++)
				sum[i] += sum[i - 1];
			for (i = n; i >= 1; i--)
				sa[sum[tt[i]]--] = tmp[i];
			for (tmp[sa[1]] = 1, k = 1, i = 2; i <= n; tmp[sa[i]] = k, i++)
				if ((rank[sa[i]] != rank[sa[i - 1]])
						|| (rank[sa[i] + j] != rank[sa[i - 1] + j]))
					k++;
			for (i = 0; i < maxn; i++) {
				rank[i] = tmp[i];
			}
		}
	}

	void calheight() {
		int i, j, k = 0;
		for (i = 1; i <= n; i++)
			if (rank[i] > 1) {
				for (j = sa[rank[i] - 1]; a[i + k] == a[j + k]; k++)
					;
				h[rank[i]] = k;
				if (k > 0)
					k--;
			}
	}

	int get(int len, boolean label) {
		int i, j, k;
		for (i = 2; i < n; i = j + 1) {
			while ((h[i] < len) && (i < n))
				i++;
			if (i >= n)
				break;
			v = new boolean[max_strings];
			for (k = 1, v[be[sa[i - 1]]] = true, j = i; h[j] >= len; j++)
				if (!v[be[sa[j]]]) {
					v[be[sa[j]]] = true;
					k++;
				}
			// if (k>=m/2+1)
			if (k >= m)
				if (label) {
					for (k = sa[i - 1]; k < sa[i - 1] + len; k++) {
						// System.out.print((char)a[k]);
						ans += (char) a[k];
					}
					// System.out.print("\n");
				} else
					return 1;
		}
		return 0;
	}

	public String getLCS() {
		int i, j, l, r, mid;
		try {
			FileReader fileReader = new FileReader(path);
			Scanner cin = new Scanner(fileReader);

			m = cin.nextInt();
			// System.out.println(m);
			for (i = 1, n = 0; i <= m; i++) {
				s = cin.next();
				// System.out.println(s);
				for (j = 0; j < s.length(); j++) {
					a[++n] = s.charAt(j);
					be[n] = i;
				}
				a[++n] = 10000 + i; // 结尾符号
			}
			if (m == 1) {
				// System.out.println(s);
				return s;
			}
			da();
			calheight();
			l = 1;
			r = max_per_len; // strlen
			while (l <= r) {
				mid = (l + r) / 2;
				if (get(mid, false) == 1)
					l = mid + 1;
				else
					r = mid - 1;
			}
			if (r != 0) { // if r==0 ans="", non-lcs
				get(r, true);
				return ans;
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return ans;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String path = "./in3w.txt";
		LCS_Suffxi lcs = new LCS_Suffxi(path);
		System.out.println(lcs.getLCS());
	}
}
